/**
 * Copyright (c) 2011-2014, homeant (junchen1314@foxmail).
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package xin.homeant.upms.service.impl;

import java.util.Set;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import xin.homeant.cache.annotation.Cache;
import xin.homeant.cache.type.CacheOpType;
import xin.homeant.upms.dao.mapper.UserMapper;
import xin.homeant.upms.model.User;
import xin.homeant.upms.service.IUserService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author homeant
 * @since 2017-05-01
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
	
	@Override
	@Cache(key="'Users'",expire=0,hfield="#args",opType=CacheOpType.READ_WRITE)
	public User getUserByUsername(String username) {
		User user = new User();
		user.setUsername(username);
		return baseMapper.selectOne(user);
	}

	@Override
	public Set<Integer> getUserRolesByUsername(String username) {
		return baseMapper.getUserRolesByUsername(username);
	}
	
}
